package logic

import (
	"baidu/baidurpc/baidurpc"
	"context"

	"baidu/api/internal/svc"
	"baidu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ForumClassAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewForumClassAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ForumClassAddLogic {
	return &ForumClassAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ForumClassAddLogic) ForumClassAdd(req *types.ForumClassAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	add, err := l.svcCtx.BaiDuRpc.ForumClassAdd(l.ctx, &baidurpc.ForumClassAddRequest{
		ClassName: req.ClassName,
		UserId:    req.UserId,
		Post:      req.PostId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "论坛分类添加成功",
		Data:    add,
		Code:    200,
	}, nil
}
